package com.leen.news.controller;

import com.leen.common.vo.ResponseVO;
import com.leen.common.vo.ResultVO;
import com.leen.news.dto.YxSystemUserLevelDTO;
import com.leen.news.dto.YxSystemUserTaskDTO;
import com.leen.news.entity.YxSystemUserLevel;
import com.leen.news.entity.YxSystemUserTask;
import com.leen.news.service.YxSystemUserTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping(value = "/news/ystask")
@Api(tags = "等级任务设置")
public class YxSystemUserTaskController {

    @Autowired
    private YxSystemUserTaskService yxSystemUserTaskService;

    @GetMapping(value = "/data")
    @ApiOperation(value = "分页查询")
    public ResultVO<ResponseVO> search(YxSystemUserTaskDTO yxSystemUserTaskDTO){
        ResponseVO search = this.yxSystemUserTaskService.search(yxSystemUserTaskDTO);
        return ResultVO.success(search);
    }


    @PostMapping(value = "/add")
    @ApiOperation(value = "添加数据")
    public ResultVO<String> insert(@RequestBody @Valid YxSystemUserTask yxSystemUserTask){
        return this.yxSystemUserTaskService.insert(yxSystemUserTask);
    }


    @PostMapping(value = "/update")
    @ApiOperation(value = "修改数据")
    public ResultVO<String> update(@RequestBody @Valid YxSystemUserTask yxSystemUserTask){
        return this.yxSystemUserTaskService.updateById(yxSystemUserTask);
    }

    @PostMapping(value = "/delete")
    @ApiOperation(value = "删除数据")
    public ResultVO<String> delete(@RequestBody @Valid YxSystemUserTask yxSystemUserTask){
        yxSystemUserTask.setIsDel(true);
        return this.yxSystemUserTaskService.updateById(yxSystemUserTask);
    }
}
